<!--
/**
* Author: zyf
* Date: 2020-07-08 14:07
* Desc: form dome
*/
-->

<template>
  <div>
      {{form}}
    <zm-form :model="form" ref="zmForm" :rules="rules">
      <zm-form-item label-width="80px" label="名字" prop="name" ref="name">
        <zm-input v-model="form.name" />
      </zm-form-item>

      <zm-form-item label-width="80px" label="密码" prop="pwd">
        <zm-input v-model="form.pwd" type="password" />
      </zm-form-item>

      <zm-form-item label-width="80px" label="类型" prop="orderType">
        <zm-data-radio v-model="form.orderType" k1="orderType" />
      </zm-form-item>

       <zm-form-item label-width="80px" label="状态" prop="select">
           <zm-data-select has-all v-model="form.select" k1="GOODS_STATUS" />
       </zm-form-item>

        <zm-form-item label-width="80px" label="生日" prop="birthday">
         <zm-date-picker type="date" v-model="form.birthday" />
      </zm-form-item>

      <zm-form-item label-width="80px" label="开关" prop="switch">
         <zm-switch type="date" v-model="form.switch" />
      </zm-form-item>

      <zm-form-item label-width="80px" label="日期" prop="start">
         <zm-date-picker has-tip :target="form" start-key="start" end-key="end" />
      </zm-form-item>
    </zm-form>

    <zm-button @click="submit" t="submit" />
    <zm-button @click="reset" t="reset" />
</div>
</template>

<script>
export default {
  name: 'MyForm',
  data () {
    return {
      form: {
        name: '123',
        start: '',
        end: '',
        pwd: '',
        birthday: '',
        orderType: '',
        select: '',
        switch: '0'
      },

      rules: {
        name: [{ required: true, message: '请输入name', trigger: 'blur' }],
        birthday: [{ required: true, message: '请选择birthday', trigger: 'change' }],
        select: [{ required: true, message: '请选择select', trigger: 'change' }],
        orderType: [{ required: true, message: '请选择orderType', trigger: 'change' }]
      }
    }
  },
  methods: {
    // 初始化方法
    init () { },

    submit () {
      this.$refs.zmForm.validate((valid) => {
        console.log(valid)
      })
    },
    reset () {
      this.$refs.zmForm.resetFields()
    }

  }
}

</script>
<style lang='scss' scoped>
</style>
